import 'package:flutter/material.dart';
import 'package:flutterdemo/components/avatar.dart';
import 'package:flutterdemo/components/icon_right.dart';
import 'package:flutterdemo/components/my_appbar.dart';
import 'package:flutter_datetime_picker/flutter_datetime_picker.dart';
import 'package:city_pickers/city_pickers.dart';

class PersonalChange extends StatefulWidget {
  PersonalChange({Key? key}) : super(key: key);

  @override
  _PersonalChangeState createState() => _PersonalChangeState();
}

class _PersonalChangeState extends State<PersonalChange> {
  // 生日
  String birthday="1995-04-12";

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: MyAppBar().getAppBar("个人信息"),
      backgroundColor: Color.fromRGBO(233, 233, 233, 1),
      body: ListView(
        physics: BouncingScrollPhysics(),
        children: [
          IconRight(
            name: "头像",
            rightWidget: Avatar(
                "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fup.enterdesk.com%2Fedpic_source%2F01%2Fb9%2Fda%2F01b9dacd2ff9cd78da62adbb2b7bc2e7.jpg&refer=http%3A%2F%2Fup.enterdesk.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1644140977&t=d201edb63a771d8d971d0a5f5f923a20"),
            onTab: () {
              print(123456);
            },
          ),
          Divider(
            height: 0,
          ),
          IconRight(name: "昵称", rightWidget: Text("我叫许士才")),
          Divider(
            height: 0,
          ),
          IconRight(name: "个性签名", rightWidget: Text("我叫许士才")),
          Divider(
            height: 0,
          ),
          IconRight(
            name: "生日",
            rightWidget: Text(birthday),
            onTab: () {
              DatePicker.showDatePicker(
                context,
                
                // 是否展示顶部操作按钮
                showTitleActions: true,
                // 当前时间
                currentTime:DateTime.now(),
                // 语言
                locale: LocaleType.zh,
                // change事件
                onChanged: (date) {
                  print('change $date');
                },
                // 确定事件
                onConfirm: (date) {
                  setState(() {
                    birthday = date.toString().split(" ")[0];
                  });
                  print('confirm $date');
                },
              );
            },
          ),
          Divider(
            height: 0,
          ),
          IconRight(name: "所在地", rightWidget: Text("贵州省-贵阳市-南明区"),onTab:  () async{
            
              var res = await CityPickers.showFullPageCityPicker(
                context: context,
              );
              print(res);
          },),
        ],
      ),
    );
  }
}
